package com.ktjiaoyu.crm.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;

@Service("redisService")
@Slf4j
public class RedisService {
    @Resource
    private RedisTemplate redisTemplate;

    public boolean set(final String key,Object value){
        boolean result=false;
        try{
            ValueOperations<Serializable,Object> operations=redisTemplate.opsForValue();
            operations.set(key,value);
            result=true;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("set error:key {},value{}",key,value,e);
        }
        return result;
    }
}
